export default {
  computed: {
    $$listensCacheTagName() {
      return this.$store.getters.cacheTagTime
    }
  },
  watch: {
    $$listensCacheTagName: {
      handler(newValue, oldValue) {
        this.$forceUpdate()
      },
      deep: true
    }
  },
  methods: {
    $$tagNameFilter(tag) {
      const title = tag.title
      let path = tag.path
      const nameReg = /\{name\}/
      Object.keys(this.$route.params).forEach(key => {
        const pathReg = new RegExp(`:${key}`)
        if (pathReg.test(path)) {
          path = path.replace(pathReg, this.$route.params[key])
        }
      })
      if (nameReg.test(title)) {
        return title.replace(nameReg, this.$store.getters.cacheTagName[path] || '加载中...')
      } else return title
    }
  }
}
